clear
clear mata
clear matrix

cd ..                                                                           /* Goes back to parent folder */

capture log close
log using "log\07_Unempl_Census.log", replace


*       Patriotism!

*       FIRST VERSION  June       7, 2022
*       THIS VERSION   June       7, 2022
*       LAST RUN       June       7, 2022

*       LAST REVISOR		AT

*       Log of revisions:

*       This prepares variables from 1937 Unemployment Census (ICPSR)

********************************************************************************
****                      PLAN OF THE PROCEDURE                             ****
****                                                                        ****
****  1. Prepare raw data  												    ****
****  2. Merge data to correspondence with counties   					    ****
****  3. Label and save 							  					    ****
********************************************************************************

do "code-build/01_Shopping_List.do"

********************************************************************************
****  1. Prepare raw data  												    ****
********************************************************************************

use "rawdata\ICPSR\02896-0030-Data", clear

keep state county emergtot unemptot punempto
drop if county == 0

foreach n in state county{
	rename `n' `n'icpsr
}

********************************************************************************
****  2. Merge data to correspondence with counties   					    ****
********************************************************************************

merge 1:1 stateicpsr countyicpsr using "rawdata\maps\Bridge", nogen keep(mat)

collapse (sum) emergtot unemptot punempto, by(stateicpsr countynd)

********************************************************************************
****  3. Label and save 							  					    ****
********************************************************************************

lab var unemptot "Total registered unemployed 1937 (Haines et al. 2010)"
lab var emergtot "Total regis emergency workers 1937 (Haines et al. 2010)"
lab var punempto "Total registered partly unemployed 1937 (Haines et al. 2010)"

save "data\unemplC37", replace

log close
exit